package com.smartx.util;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Color;
import cn.bertsir.zbar.QRConfig;
import cn.bertsir.zbar.QRManager;
import cn.bertsir.zbar.QRUtils;

import com.smartx.app.R;
public class ZbarUtil {

    static {
        QRConfig config = new QRConfig.Builder()
                .setShowDes(false)
                .setCornerColor(ResourceUtil.getColor(R.color.colorPrimary))
                .setLineColor(Color.WHITE)
                .setPlaySound(true)
                .setTitleText("Scan QRCode")
                .setTitleBackgroudColor(ResourceUtil.getColor(R.color.colorPrimary))
                .setTitleTextColor(Color.WHITE)
                .create();

        QRManager.getInstance().init(config);
    }


    public static void startScan(final Activity activity, QRManager.OnScanResultCallback callback) {
        QRManager.getInstance().startScan(activity, callback);
    }

    public static Bitmap createQRCode(String content) {
        return QRUtils.getInstance().createQRCode(content, DensityUtil.dp2px(200), DensityUtil.dp2px(200));
    }
}